Skip to content

feat(apphost): add Pocket ID as an auth provider with PocketIdSeeder - #540

Draft
pdevito3 wants to merge 8 commits into
mainfrom
feat/pocketid-provider
Draft

pdevito3 wants to merge 8 commits into
mainfrom
feat/pocketid-provider

Conversation

@pdevito3

Copy link
Copy Markdown
Owner

Why

Add Pocket ID v2.19.3 as one more local OIDC provider. AuthProvider=PocketId starts it in Docker, seeds it with no manual steps, and the e2e auth flows run against it. Draft: do not merge yet. See the open decisions.

What changed

  • PocketIdAuthProvider adds the pocketid container (port 24790). PocketIdSeeder runs as its health check and brings the admin API to the seed state: groups, two test users with the Keycloak and ZeroFactor IDs, and the aspire-app client with a fixed secret. Each step reads the current state and then creates or updates, so a kept volume converges. The BFF and the server wait for the check.
  • Pocket ID has passkeys and no passwords. The seed prints one login link for each test user to the pocketid console log, and the command "Print login links" prints new ones.
  • The server refuses a Pocket ID ID token (type: id-token) as an access token. Before, it answered 200.
  • Swagger UI drops X-Requested-With from its token request. Pocket ID CORS allows only Authorization.
  • New e2e IdP file with a login-code login, a CI matrix leg, and the docs and port table.

Tradeoffs

  • The seeder is C# in the AppHost, not a seed script. The image has no curl or jq, and busybox wget cannot send PUT.
  • DISABLE_RATE_LIMITING=true, because the e2e run hit a 429 after five login codes. The AppHost refuses Pocket ID in publish mode.

Open decisions for later

  1. "Signed in as ". The Pocket ID access token has only sub, client_id, and the scopes, and no setting adds email or name. A fix needs the server to get the profile from somewhere else, for example userinfo. That logic is not in this PR, so that the template does not grow for one provider.
  2. Invites do not match by email on Pocket ID, for the same reason. One server change fixes both 1 and 2.
  3. A client_credentials token reads as a user (review gate L1). Pocket ID gives the client_credentials grant to each confidential client, with no switch to turn it off. The token has sub client-aspire-app, so the server takes it as a user of the first-party client. Keycloak blocks this with serviceAccountsEnabled: false. Fix by refusing sub client-{client_id}, or document it.
  4. An interrupted back-channel test leaves the admin disabled (L2) until the AppHost restarts. Re-enable the user at the start of the test as well.
  5. AuthProviderCatalogTests skips each provider with no seed/ folder (L4). Exempt only Pocket ID instead.
  6. The Swagger change touches every provider. It was run again only on ZeroFactor. Run the Swagger login on Keycloak and Authentik before a merge.

Verification

  • dotnet build has 0 warnings. The .NET tests, pnpm lint, and pnpm build pass.
  • Against AuthProvider=PocketId --isolated: pnpm test:e2e:stack gave 10 passed, 4 skipped. With --repeat-each=3: 30 passed, 12 skipped, 0 flaky. The skips are DPoP, and the three refresh-rotation tests (Pocket ID accepts the old refresh token for 60 s).
  • A second start that kept the volume updated the seed and added no secret. Login and back-channel logout still passed.
  • Browser: login link, then the app signed in, then logout to the Pocket ID sign-in page.
  • The CI leg has not run yet.

A Pocket ID ID token has the client ID as its aud, so the server took it
as an access token. It has the claim type=id-token, and the access token
has no type claim.
The header needs a CORS preflight. Pocket ID allows only Authorization,
so the token request of Swagger UI failed there.
The AppHost seeds Pocket ID through its admin API in a health check, so
the BFF and the server wait for the seed. Each start creates or updates
the groups, the test users with the Keycloak IDs, and the client, and
prints a login link for each test user.
The tests sign in with a login code from the admin API. The back-channel
test disables the user, which makes Pocket ID send the logout token.
…et ID in publish mode, and drop restating comments
@pdevito3

Copy link
Copy Markdown
Owner Author

review-gate: passed 7ac0895

No high or medium finding. The low findings that stay open, with reasons:

  • L1: a client_credentials token of the first-party client reads as a user. Local only, with a committed secret. Kept as open decision 3.
  • L2: an interrupted back-channel test leaves the admin disabled until the AppHost restarts. Test-only. Kept as open decision 4.
  • L4: the catalog test skips each provider with no seed folder. Kept as open decision 5.

Fixed after the review: L3 (publish-mode guard) in 63b2f8c, and nit 3 (Swagger interceptor comment) in d70854f. Nits 1 and 2 (TS casts, the Pocket ID-only shape of IdpLoginCode) stay as they are. The file already uses that style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant